package avicit.bdp.oss.dto;

import avicit.bdp.common.base.BaseDTO;
import avicit.platform6.core.annotation.log.FieldRemark;
import avicit.platform6.core.annotation.log.Id;
import avicit.platform6.core.annotation.log.LogField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.lang3.StringUtils;

import javax.persistence.Column;
import javax.persistence.Table;

/**
 * @金航数码科技有限责任公司
 * @作者：developer
 * @邮箱：developer@avic-digital.com
 * @创建时间： 2020-11-12
 * @类说明：BucketAuditDto
 * @修改记录：
 * @注意事项：
 * @主要功能：记录bucket上传、下载日志
 */
@ApiModel(value = "BucketAuthDto", description = "bdp_oss_bucket_audit")
@Table(name = "bdp_oss_bucket_audit")
public class BucketAuditDto extends BaseDTO {
    /**
     * 主键
     */
    @Id
    @LogField
    @ApiModelProperty(value = "主键")
    @FieldRemark(column = "id", field = "id", name = "id")
    @javax.persistence.Id
    @Column(name = "id")
    private String id;

    /**
     * 桶ID
     */
    @LogField
    @ApiModelProperty(value = "桶ID")
    @FieldRemark(column = "bucket_id", field = "bucket_id", name = "桶ID")
    @Column(name = "bucket_id")
    private String bucketId;

    /**
     * 对象ID
     */
    @LogField
    @ApiModelProperty(value = "对象ID")
    @FieldRemark(column = "object_id", field = "object_id", name = "对象ID")
    @Column(name = "object_id")
    private String objectId;

    /**
     * 时间戳
     */
    @LogField
    @ApiModelProperty(value = "时间戳")
    @FieldRemark(column = "stamp", field = "stamp", name = "时间戳")
    @Column(name = "stamp")
    private long stamp;

    /**
     * 操作类型
     */
    @LogField
    @ApiModelProperty(value = "操作类型，当前仅支持PUT/GET")
    @FieldRemark(column = "action", field = "action", name = "操作类型")
    @Column(name = "action")
    private String action;

    /**
     * 流量
     */
    @LogField
    @ApiModelProperty(value = "流量")
    @FieldRemark(column = "traffic", field = "traffic", name = "流量")
    @Column(name = "traffic")
    private long traffic;

    /**
     * 无参构造函数，mybatis使用
     */
    public BucketAuditDto() {
    }

    public BucketAuditDto(String id, String bucketId, String objectId, long stamp, String action, long traffic) {
        this.id = id;
        this.bucketId = bucketId;
        this.objectId = objectId;
        this.stamp = stamp;
        this.action = action;
        this.traffic = traffic;
    }

    public String getId() {
        return id;
    }

    public String getBucketId() {
        return bucketId;
    }

    public String getObjectId() {
        return objectId;
    }

    public long getStamp() {
        return stamp;
    }

    public String getAction() {
        return action;
    }

    public long getTraffic() {
        return traffic;
    }

    public void setId(String id) {
        this.id = id;
    }

    public void setBucketId(String bucketId) {
        this.bucketId = bucketId;
    }

    public void setObjectId(String objectId) {
        this.objectId = objectId;
    }

    public void setStamp(long stamp) {
        this.stamp = stamp;
    }

    public void setAction(String action) {
        this.action = action;
    }

    public void setTraffic(long traffic) {
        this.traffic = traffic;
    }

    @Override
    public String getLogFormName() {
        if (StringUtils.isEmpty(super.logFormName)) {
            return "桶操作日志管理";
        } else {
            return super.logFormName;
        }
    }

    @Override
    public String getLogTitle() {
        if (StringUtils.isEmpty(super.logTitle)) {
            return "桶操作日志";
        } else {
            return super.logTitle;
        }
    }

    public static BucketAuditDto.Builder builder() {
        return new BucketAuditDto.Builder();
    }

    public static final class Builder {
        String id;
        String bucketId;
        String objectId;
        long stamp;
        String action;
        long traffic;

        public Builder() {
        }

        public BucketAuditDto.Builder id(String id) {
            this.id = id;
            return this;
        }

        public BucketAuditDto.Builder bucketId(String bucketId) {
            this.bucketId = bucketId;
            return this;
        }

        public BucketAuditDto.Builder objectId(String objectId) {
            this.objectId = objectId;
            return this;
        }

        public BucketAuditDto.Builder stamp(long stamp) {
            this.stamp = stamp;
            return this;
        }

        public BucketAuditDto.Builder action(String action) {
            this.action = action;
            return this;
        }

        public BucketAuditDto.Builder traffic(long traffic) {
            this.traffic = traffic;
            return this;
        }

        public BucketAuditDto build() {
            return new BucketAuditDto(id, bucketId, objectId, stamp, action, traffic);
        }
    }
}
